" All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by
" the call to :runtime you can find below.  If you wish to change any of those
" settings, you should do it in this file (/etc/vim/vimrc), since debian.vim
" will be overwritten everytime an upgrade of the vim packages is performed.
" It is recommended to make changes after sourcing debian.vim since it alters
" the value of the 'compatible' option.

" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

" Vim will load $VIMRUNTIME/defaults.vim if the user does not have a vimrc.
" This happens after /etc/vim/vimrc(.local) are loaded, so it will override
" any settings in these files.
" If you don't want that to happen, uncomment the below line to prevent
" defaults.vim from being loaded.
" let g:skip_defaults_vim = 1

" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
syntax on

" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark

" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
"  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif

" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
"  filetype plugin indent on
"endif

" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
set showcmd		" Show (partial) command in status line.
set showmatch		" Show matching brackets.
set ignorecase		" Do case insensitive matching
set smartcase		" Do smart case matching
set number
set incsearch		" Incremental search
set autowrite		" Automatically save before commands like :next and :make
set hidden		" Hide buffers when they are abandoned
set mouse=a		" Enable mouse usage (all modes)

set guifont=Monospace\ Bold\ 14
colorscheme desert

set nocompatible 
set ruler
set nobackup
set autoindent
set smartindent
let Tlist_Show_One_File=1    "只显示当前文件的tags
let Tlist_WinWidth=20        "设置taglist宽度
let Tlist_Exit_OnlyWindow=1  "tagList窗口是最后一个窗口，则退出Vim
let Tlist_Use_Left_Window=1 "在Vim窗口右侧显示taglist窗口
let Tlist_Show_Menu=1
let Tlist_Auto_Open=1
set tags=.\tags,.\..\tags,.\*\tags


" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif

autocmd BufNewFile *.py exec ":call SetPyTitle()" 
func SetPyTitle()
	call setline(1,"#!/usr/bin/python") 
	call append(line("."),   "#Author:sq")
	call append(line(".")+1, "#Filename:".expand("%:t"))
	call append(line(".")+2, "#Date    :".strftime("%Y-%m-%d"))  
	call append(line(".")+3, "#Describe:nothing")
 	call append(line(".")+4, "")
	call append(line(".")+5, "if __name__=='__main__':") 

endfunc

autocmd BufNewFile *.[ch],*.hpp,*.cpp,*.java exec ":call SetTitle()" 

func SetComment()
	call setline(1,"/********************************************************") 
	call append(line("."),   "*   Copyright (C) ".strftime("%Y")." All rights reserved.")
	call append(line(".")+1, "*   ") 
	call append(line(".")+2, "*   Filename:".expand("%:t")) 
	call append(line(".")+3, "*   Author  :aquan")
	call append(line(".")+4, "*   Date    :".strftime("%Y-%m-%d")) 
	call append(line(".")+5, "*   Describe:nothing") 
	call append(line(".")+6, "*")
	call append(line(".")+7, "********************************************************/") 
endfunc

func SetTitle()
	call SetComment()
	if expand("%:e") == 'hpp' 
	call append(line(".")+8, "#ifndef _".toupper(expand("%:t:r"))."_H") 
	call append(line(".")+9, "#define _".toupper(expand("%:t:r"))."_H") 
	call append(line(".")+10, "#ifdef __cplusplus") 
	call append(line(".")+11, "extern \"C\"") 
	call append(line(".")+12, "{") 
	call append(line(".")+13, "#endif") 
	call append(line(".")+14, "") 
	call append(line(".")+15, "#ifdef __cplusplus") 
	call append(line(".")+16, "}") 
	call append(line(".")+17, "#endif") 
	call append(line(".")+18, "#endif //".toupper(expand("%:t:r"))."_H") 
	elseif expand("%:e") == 'h' 
	call append(line(".")+8, "#ifndef _".toupper(expand("%:t:r"))."_H") 
	call append(line(".")+9, "#define _".toupper(expand("%:t:r"))."_H") 
	call append(line(".")+10," ") 
	call append(line(".")+11, "#endif") 
	call append(line(".")+12, "#endif //".toupper(expand("%:t:r"))."_H") 
	
	elseif &filetype == 'c' 
	call append(line(".")+8,"#include<stdio.h>")  
	call append(line(".")+9, "")
 	call append(line(".")+10, "int main(int argc, char *argv[])")
 	call append(line(".")+11, "{")
 	call append(line(".")+12, "\tprintf(\"hello,linux\\n\");")	
 	call append(line(".")+13, "\treturn 0;")	
 	call append(line(".")+14, "}")	
	elseif &filetype == 'cpp' 
	call append(line(".")+8, "#include<iostream>") 
	call append(line(".")+9, "using namespace std;")
 	call append(line(".")+10, "int main(int argc, char *argv[])")
 	call append(line(".")+11, "{")
 	call append(line(".")+12, "cout<<"hi"<<endl;")	
 	call append(line(".")+13, "\treturn 0;")	
 	call append(line(".")+14, "}")		
	elseif &filetype == 'java' 
	call append(line(".")+8, "")
	
	endif
endfunc
nmap    w=  :resize +3<CR>
nmap    w-  :resize -3<CR>
nmap    w,  :vertical resize -3<CR>
nmap    w.  :vertical resize +3<CR>
